package com.xsnet.grpc;


import io.grpc.ManagedChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HelloClient {

    @Autowired
    private ManagedChannel channel;

    @RequestMapping("/hello")
    public String hello() {
        HelloGrpc.HelloBlockingStub blockingStub = HelloGrpc.newBlockingStub(channel);
        HelloOuterClass.HelloRequest request = HelloOuterClass.HelloRequest.newBuilder().setName("Jamie").build();
        HelloOuterClass.HelloReply res = blockingStub.sayHello(request);
        System.out.println(res.getMessage());
        return res.getMessage();
    }

}
